mui.init();
var start = 1;
var limit = 10;
var self;
mui.plusReady(function() {
	self = plus.webview.currentWebview();
	initData();
	initListener();
})

window.addEventListener("reloadView", function() {
	start = 1;
	$("#ul_biaoduan").html("");
	initData();

})

function initData() {
	plus.nativeUI.showWaiting();
	ajaxF1(GETSGCLIST, {
		start: start,
		limit: limit,
		id: self.ID
	}, function(result) {
		console.log(JSON.stringify(result));
		var $myOrder11 = $("#mylist").find('li').eq(0);

		if(result.successful) {
			var data = result.resultValue;
			for(var i in data) {
				var $myOrder = $myOrder11.clone();
				$myOrder.attr("ID", data[i].ID);
				$myOrder.find(".center span").html("第" + data[i].SGCH + "处");
				$myOrder.find(".div_title").html(data[i].SGCMC);
				$myOrder.find(".div_nr").html(data[i].SGBZ);
				$myOrder.find(".sghj").html(data[i].HJ);
				$myOrder.find(".ywc").html(data[i].YWC);
				if(data[i].JXZ > 0) {
					$myOrder.find(".icon-iconluxiang").eq(0).css("color", "blue");
				}
				$("#ul_biaoduan").append($myOrder);
			}
			if(data && data.length === limit) {
				start += 1;
				if(mui("#div_addMore")[0].classList.contains("mui-hidden")) {
					mui("#div_addMore")[0].classList.remove("mui-hidden")
				}
			} else {
				if(!mui("#div_addMore")[0].classList.contains("mui-hidden")) {
					mui("#div_addMore")[0].classList.add("mui-hidden")
				}
			}
		}
		plus.nativeUI.closeWaiting();
	}, function() {
		mui.toast("请求失败");
		plus.nativeUI.closeWaiting();

	});
}

function initListener() {
	$("#ul_biaoduan").on("tap", "li", function() {
		jumpTo('../sjtz/sjtz.html', 'sjtz.html', jumpOptionFadein, {
			ID: $(this).attr("ID")
		})
	})
	$(".icon_back").on("tap", function() {
		mui.back();
	})
	mui("#div_addMore")[0].addEventListener("tap", function() {
		initData();
	});
	$("#ul_biaoduan").on("tap", "li .iconfont.icon-iconluxiang", function(event) {
		//修改标段
		var SGCID = $(this).parents("li").attr("ID");
		jumpTo('../monitor/monitor.html', 'monitor.html', jumpOptionFadein, {
			SGCID: SGCID
		})
		event.stopImmediatePropagation();
	})
}